package org.lsms.servlet;

/**
 * servlet used to process deny paper(more than one paper)
 * @author ZhanXueliang
 * 2010.9.1
 */

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lsms.dao.impl.DaoImpl;

public class deny_selected_paper extends HttpServlet {

	
	public void destroy() {
		super.destroy(); 
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			
			String paper_ids = request.getParameter("paper_id");
			String [] ids = paper_ids.split(",");
			System.out.println(ids);
			
			DaoImpl impl = new DaoImpl();
			
			for(int i=0;i<ids.length;i++){
				int paper_id = Integer.parseInt(ids[i]);
				if(impl.update_paper_status(2, paper_id)){
					continue;
				}else{
					String chair_info = "Problem occurs when decision submit!\n " +
							"Please try again later.";
					response.sendRedirect("chair/chair_show_info.jsp?chair_info="+chair_info);
				}
			}
			String chair_info = "Decision submit succeed!";
			response.sendRedirect("chair/chair_show_info.jsp?chair_info="+chair_info);
	}

	public void init() throws ServletException {
		
	}

}
